package diplomovka.graphCreator;

import java.util.Map;

import org.apache.bcel.classfile.JavaClass;
import org.jdom.Element;

import diplomovka.graphCreator.modelParts.MException;
import diplomovka.graphCreator.modelParts.Type;

public class ExceptionCreator implements ModelPartCreator {

	@Override
	public boolean canHandle(Class loadedClass) {
		Class superclass = loadedClass.getSuperclass();
		while (superclass != null) {
			if (superclass != null && superclass.getSimpleName().equals("Exception"))
				return true;
			superclass = superclass.getSuperclass();
		}
				
		return false;
	}

	@Override
	public Type createModelPart(Class loadedClass, JavaClass loadedByteCode,
			Map<String, Element> configFiles) {
		MException exception = new MException();
		exception.setName(loadedClass.getName());
		exception.setPackageName(loadedClass.getPackage().getName());
		
		return exception;
	}

	
}
